/***
 * @Author solq
 * @link 淘宝搜 海豚工具店
 * */

#ifndef MODULES_COMMON_H_
#define MODULES_COMMON_H_

//system include
#include <mutex>
#include <map>
#include <vector>
#include <atomic>
#include <hash_map>
#include <Stream.h>

//user include
#include "config.h"
#include "rapidjson/AIGCJson.hpp"
#include "core/log.h"
#include "core/IBean.h"
#include "core/IocService.h"
#include "core/Event.h"
#include "core/RepositoryService.h"
#include "core/Random.h"
#include "core/PinWrap.h"
#include "core/Timer.h"
#include "core/Task.h"
#include "core/DeepSleepService.h"
#include "wifi/WifiService.h"
#include "mqtt/MQTTService.h"
#include "serial/SerialService.h"
#include "cmd/CmdService.h"
#include "minimp3/MiniMp3Service.h"
#include "core/EventService.hpp"
//#include "audio/AudioService.h"

#ifdef CONFIG_OPEN_P2P__
#include <AsyncUDP.h>
#include "core/P2PService.h"
#endif

#ifdef CONFIG_OPEN_HTTP__
#include "resthttp/RestHttpService.h"
#include "motor/MotorService.h"
#endif

#ifdef CONFIG_OPEN_TEST__
#include "test/TestService.h"
#endif
using namespace aigc;

class AppContext {
public:
	app_create_field(CmdService)
	app_create_field(SerialService)
	app_create_field(WifiService)
	app_create_field(RepositoryService)
	app_create_field(TestService)
	app_create_field(MQTTService)
	app_create_field(MiniMp3Service)
//beans
//	static MotorService motorService;
//	static AudioService audioService;
// 	static DeepSleepService deepSleepService;


	static void init() {
		iocService.init();
		iocService.prepare0();
		iocService.prepare();
		iocService.start();
	}
	static void close() {
		Task::shutdown();
		iocService.close();
	}
	static void loop() {
		if (Task::isShutdown()) {
			return;
		}
		iocService.loop();
	}
};
extern AppContext App;

#endif /* MODULES_COMMON_H_ */
